#ifndef __SOCKETDATASOURCE_TOOL_H__
#define __SOCKETDATASOURCE_TOOL_H__

#include "../stdaxf.h"
#ifdef __QT_ENV_US__
#include <QtNetwork/QTcpSocket>
#elif defined(Q_OS_LINUX)
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <sys/shm.h>
#include <unistd.h>
#include <errno.h>
#else
#include <winsock2.h>
#pragma comment(lib,"ws2_32.lib")
#endif

//该数据源使用同步读写的方式
class SocketDataSourceTool
{
public:
    SocketDataSourceTool();
    SocketDataSourceTool(int tcpPort, const char* peername);
    ~SocketDataSourceTool();
public:
	bool IsEof();
    bool Connect(int tcpPort, const char* peername);
    bool isConnect();
    void Close();
    int FetchNext(char *buf, int bufsize);
    void Send(const char *message, int count);
#ifdef __QT_ENV_US__
private:
    QTcpSocket *sock_client;

#elif defined(Q_OS_LINUX)
private:
    int sock_client;
#elif WIN32
private:
    SOCKET sock_client;
#endif
};
#endif 
